﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BHXJDOTNET.NEW
{
    public partial class BHXJTimeSpan : BHXJContainer
    {
        public BHXJTimeSpan()
        {
            InitializeComponent();
            this.StartDate.CustomFormat = "yyyy-MM-dd";
            this.StopDate.CustomFormat = "yyyy-MM-dd";
            this.StartTime.CustomFormat = "HH:mm";
            this.StopTime.CustomFormat = "HH:mm";
        }

        public bool Checked
        {
            get { return this.bhxjCheckBox1.Checked; }
            set
            {
                this.bhxjCheckBox1.Checked = value;
            }
        }

        /// <summary>
        /// 获取起始时间
        /// </summary>
        /// <returns></returns>
        public DateTime GetStartTime()
        {
            DateTime result;

            if (this.StartTime.Checked)
                result = new DateTime(this.StartDate.Value.Year, this.StartDate.Value.Month, this.StartDate.Value.Day, this.StartTime.Value.Hour, this.StartTime.Value.Minute, 0);
            else
                result = new DateTime(this.StartDate.Value.Year, this.StartDate.Value.Month, this.StartDate.Value.Day);
            return result;
        }
        /// <summary>
        /// 获取结束时间
        /// </summary>
        /// <returns></returns>
        public DateTime GetStopTime()
        {
            DateTime result;

            if (this.StopTime.Checked)
                result = new DateTime(this.StopDate.Value.Year, this.StopDate.Value.Month, this.StopDate.Value.Day, this.StopTime.Value.Hour, this.StopTime.Value.Minute, 0);
            else
                result = new DateTime(this.StopDate.Value.Year, this.StopDate.Value.Month, this.StopDate.Value.Day);
            return result;
        }
    }
}
